-- @owner: cr13
-- @date: 2023-05-11
-- @testpoint: opengauss关键字algorithm(非保留)，作为触发器名，合理报错

--step1:创建表1,2 expect:成功
drop table if exists t_keywords_algorithm_0030_01,t_keywords_algorithm_0030_02;
create table t_keywords_algorithm_0030_01(id1 int, id2 int, id3 int);
create table t_keywords_algorithm_0030_02(id1 int, id2 int, id3 int);

--step2:创建触发器函数 expect:成功
create or replace function f_keywords_algorithm_0030() returns trigger as $$
declare
begin
    insert intO t_keywords_algorithm_0030_02 values(new.id1, new.id2, new.id3);
    return new;
end
$$ language plpgsql;
/

--step3:创建insert触发器不带引号 expect:创建成功
drop trigger if exists algorithm on t_keywords_algorithm_0030_01;
create trigger algorithm before insert on t_keywords_algorithm_0030_01 for each row execute procedure f_keywords_algorithm_0030();
/

--step4:创建insert触发器带双引号 expect:创建成功
drop trigger if exists "algorithm" on t_keywords_algorithm_0030_01;
create trigger "algorithm" before insert on t_keywords_algorithm_0030_01 for each row execute procedure f_keywords_algorithm_0030();
/

--step5:创建insert触发器带单引号 expect:合理报错
drop trigger if exists 'algorithm' on t_keywords_algorithm_0030_01;
create trigger 'algorithm' before insert on t_keywords_algorithm_0030_01 for each row execute procedure tri_insert_func();
/

--step6:创建insert触发器带反单引号 expect:合理报错
drop trigger if exists `algorithm` on t_keywords_algorithm_0030_01;
create trigger `algorithm` before insert on t_keywords_algorithm_0030_01 for each row execute procedure tri_insert_func();
/

--step7:清理环境 expect:成功
drop trigger if exists algorithm on t_keywords_algorithm_0030_01;
drop table if exists t_keywords_algorithm_0030_01,t_keywords_algorithm_0030_02;
drop function f_keywords_algorithm_0030;